package com.bjpowernode.crm.workbench.service.impl;

import com.bjpowernode.crm.commons.utils.DateUtils;
import com.bjpowernode.crm.commons.utils.UUIDUtils;
import com.bjpowernode.crm.workbench.domain.TranHistory;
import com.bjpowernode.crm.workbench.mapper.TranHistoryMapper;
import com.bjpowernode.crm.workbench.service.TranHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 郭俊才
 * 2021/8/30
 */
@Service
public class TranHistoryServiceImpl implements TranHistoryService {
    @Autowired
    private TranHistoryMapper tranHistoryMapper;

    @Override
    public int saveSelective(TranHistory record) {
        //设置主键
        record.setId(UUIDUtils.getUUID());
        //设置创建时间
        record.setCreateTime(DateUtils.formatDateTime(new Date()));
        return tranHistoryMapper.insertSelective(record);
    }

    @Override
    public int removeByPrimaryKey(String id) {
        return tranHistoryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int editByPrimaryKeySelective(TranHistory record) {
        return tranHistoryMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public TranHistory queryByPrimaryKey(String id) {
        return tranHistoryMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<TranHistory> queryAll() {
        return tranHistoryMapper.selectAll();
    }

    @Override
    public List<TranHistory> queryByTranPrimaryKeyForDetails(String tranId) {
        return tranHistoryMapper.selectByTranPrimaryKeyForDetails(tranId);
    }

}